#ifndef _BLOOM_H_
#define _BLOOM_H_

#include "global.h"

typedef u_int32 (*HASH_FUNC)(const char *str, u_int32 len);

enum ERROR_CODE
{
	EXIST				=	1001,
	NOT_EXIST			=	1000,
	SUCCESS				=	 0,
	CREATE_BLOOM_ERROR	=	-1,
	CONFLICT_ERROR		=	-2,
	SIZE_OVERFLOW_ERROR =	-3,
	NULL_POINTER		=	-4
	
};

typedef struct Bloom
{
	HASH_FUNC func1;
	HASH_FUNC func2;
	HASH_FUNC func3;
	HASH_FUNC func4;
	u_int32 *map;
	u_int32 size;
	u_int32 bit_size;
	u_int32 size_mask;
	double error_rate;
	
}Bloom, *PBloom;


u_int32 init_bloom(PBloom p_bloom, u_int32 size, double error_rate);
u_int32 add_ele(PBloom p_bloom, const char *str);
u_int32 check_ele(PBloom p_bloom, const char *str);
void clean_bloom(PBloom p_bloom);
void destroy_bloom(PBloom p_bloom);


#endif
